﻿using Expect.Core.Interfaces;

namespace Expect.Core
{    
    /// <summary>
    /// Base class for fixtures
    /// </summary>
    public abstract class AbstractFixture : IFixtureImplementation
    {
        /// <summary>
        /// Context of the execution
        /// </summary>
        public IExecutionContext Context
        {
            get
            {
                return Specification.Context;
            }
            set
            {
                Specification.Context = value;
            }
        }

        /// <summary>
        /// Current specification
        /// </summary>
        public SpecificationDefinition Specification { get; set; }

        /// <summary>
        /// Fixture definition
        /// </summary>
        public FixtureDefinition Fixture { get; set; }

        /// <summary>
        /// Current row
        /// </summary>
        public FixtureRow Row { get; set; }

        /// <summary>
        /// Fill arguments and definition if necessary
        /// </summary>
        /// <returns></returns>
        public virtual void Resolve()
        {
        }

        /// <summary>
        /// Execute the fixture for the provided row
        /// </summary>
        public abstract bool? RunRow();

        #region IFixtureImplementation Members

        /// <summary>
        /// Called when there is no more rows to process
        /// </summary>
        public virtual void EndRun()
        {
        }

        #endregion
    }
}
